package com.nanyang.tms.manager.forecast.handler.weight;

import java.math.BigDecimal;

import org.apache.dubbo.config.annotation.Reference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.nanyang.common.core.dict.CommonEnum;
import com.nanyang.common.core.domain.ApiResult;
import com.nanyang.common.core.flow.context.TransHandlerContext;
import com.nanyang.sys.api.dto.response.dict.DictionaryResponse;
import com.nanyang.sys.api.service.dict.DictionaryRpcService;
import com.nanyang.tms.common.dict.TmsCalculateWeightEnum;
import com.nanyang.tms.common.dict.TmsExceptionEnum;
import com.nanyang.tms.common.exception.TmsManagerException;
import com.nanyang.tms.dao.saleproduct.SaleProductCarryRuleDao;
import com.nanyang.tms.dao.saleproduct.SaleProductWeightModelDao;
import com.nanyang.tms.dao.saleproduct.SaleProductWeightRuleDao;
import com.nanyang.tms.domain.forecast.context.CalculateWeightContext;
import com.nanyang.tms.domain.saleproduct.SaleProductWeightModelVO;
@Component
public class CalculateWeightByB extends AbstractCalculateWeight{
	private static final String CARGO_TYPE="CARGO_TYPE_CODE";
	private static final String C_EXPRESS="(length+width+height)*4";//周长公式
	private static final String V_EXPRESS="length*width*height";//体积公式
	private static final String VM_EXPRESS="(length*width*height)/factor";// 材积重公式
	private static final String CARRY_EXPRESS= "if (carryTypeCode == 'weight') " //进位计算公式
		 + "then "
		 +   "if( remainder > 0) "
		 +   "then "
		 +     "return quotient * carryValue + carryValue; "
		 +	" else "
		 +	   "return quotient * carryValue; "
		 + " if (carryTypeCode == 'round') "  
		 + " return round(totalChargeWeight,3); ";
	
    @Autowired
	private SaleProductWeightRuleDao saleProductWeightRuleDao;
    @Autowired
    private SaleProductCarryRuleDao saleProductCarryRuleDao;
    @Autowired
	private SaleProductWeightModelDao saleProductWeightModelDao;
    @Reference(version = "1.0.0", timeout = 10000, check = false)
	private DictionaryRpcService  dictionaryRpcService;
	@Override
	public String getCalculateType() {
		return TmsCalculateWeightEnum.JZZ.getTypeCode();
	}

	@Override
	public boolean generalProcess(TransHandlerContext context) {
		CalculateWeightContext calculateWeightContext=(CalculateWeightContext) context.getInnerContext(CalculateWeightContext.class);
		
		SaleProductWeightModelVO selectBySaleProductCode = saleProductWeightModelDao.selectBySaleProductCode(calculateWeightContext.getSaleProductCode());
		//selectBySaleProductCode.get
		
		
		
		
		
		return true;
	}
}
